#include <iostream>

int const mo = 1000000007;

long long quick_two(int x)
{
	if (!x) return 1;
	long long tmp = quick_two(x/2);
	tmp = (tmp * tmp) % mo;
	if (x & 1) tmp *= x;
	return (tmp % mo);
}

int main()
{
	std::ios::sync_with_stdio(false);
	int T, n;
	std::cin >> T;
	while (T--) {
		std::cin >> n;
		std::cout << quick_two(n-2) << '\n';
	}

}
